package action

import (
	"../global"
	"../model"
	"git.oschina.net/dxvgef/go-lib/validation"
	"github.com/go-pg/pg"
	"github.com/labstack/echo"
	"strconv"
	"strings"
	"time"
)

type Order struct{}

//定义查询用的产品结构体
var Items []struct {
	ID   int64
	Name string
}

//获取未完成的订单首页列表
func (*Order) NowOrderIndex(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""

	response["items"] = Items
	//定义订单模型，查询订单
	var Model model.OrderTradeInCompleteModel
	var query model.OrderTradeInComplete
	if ctx.QueryParam("mobile") != "" {
		query.UserID = GetUserID("mobile", ctx.QueryParam("mobile"))
	}
	if ctx.QueryParam("nickname") != "" {
		query.UserID = GetUserID("nickname", ctx.QueryParam("nickname"))
	}
	if ctx.QueryParam("fullname") != "" {
		query.UserID = GetUserID("fullname", ctx.QueryParam("fullname"))
	}
	if ctx.QueryParam("item_id") != "" {
		if query.ItemID, err = strconv.ParseInt(ctx.QueryParam("item_id"), 10, 64); err != nil {
			global.Logger.Error("item_id数据类型转换是失败：" + err.Error())
			query.ItemID = 0
		}
	}
	if ctx.QueryParam("buy_time") != "" {
		t, err := time.ParseInLocation("2006-01-02T15:04", ctx.QueryParam("buy_time"), global.TimeLocal)
		if err != nil {
			global.Logger.Error("buy_time数据类型转换是失败：" + err.Error())
			query.BuyTime = 0
		}
		query.BuyTime = t.Unix()
	}
	if ctx.QueryParam("sell_time") != "" {
		t, err := time.ParseInLocation("2006-01-02T15:04", ctx.QueryParam("sell_time"), global.TimeLocal)
		if err != nil {
			global.Logger.Error("sell_time数据类型转换是失败：" + err.Error())
			query.SellTime = 0
		}
		query.SellTime = t.Unix()
	}
	if query.SellTime != 0 && query.BuyTime != 0 && query.SellTime < query.BuyTime {
		response["error"] = "订单结束时间不能小于订单购买时间"
		return ctx.JSON(200, response)
	}
	//根据条件查询订单
	res, err := Model.GetOrder(&query, []string{}, &model.ListParams{})
	if err != nil {
		global.Logger.Error("查询订单错误：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	if len(res) == 0 {
		response["data"] = ""
	} else {
		response["data"] = res
	}

	_, err = global.DB.Query(&Items, `SELECT "id", "name" FROM item`)
	if err != nil {
		global.Logger.Error("查询产品错误：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	response["items"] = Items

	return ctx.JSON(200, response)
}

//获取历史订单首页列表，包含统计数据
func (*Order) HistoryOrderIndex(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""

	//定义订单模型，查询订单
	var Model model.OrderTradeCompletedModel
	var query model.OrderTradeCompleted
	if ctx.QueryParam("mobile") != "" {
		query.UserID = GetUserID("mobile", ctx.QueryParam("mobile"))
	}
	if ctx.QueryParam("nickname") != "" {
		query.UserID = GetUserID("nickname", ctx.QueryParam("nickname"))
	}
	if ctx.QueryParam("fullname") != "" {
		query.UserID = GetUserID("fullname", ctx.QueryParam("fullname"))
	}
	if ctx.QueryParam("item_id") != "" {
		if query.ItemID, err = strconv.ParseInt(ctx.QueryParam("item_id"), 10, 64); err != nil {
			global.Logger.Error("item_id数据类型转换是失败：" + err.Error())
			query.ItemID = 0
		}
	}
	if ctx.QueryParam("buy_time") != "" {
		t, err := time.ParseInLocation("2006-01-02T15:04", ctx.QueryParam("buy_time"), global.TimeLocal)
		if err != nil {
			global.Logger.Error("buy_time数据类型转换是失败：" + err.Error())
			query.BuyTime = 0
		}
		query.BuyTime = t.Unix()
	}
	if ctx.QueryParam("sell_time") != "" {
		t, err := time.ParseInLocation("2006-01-02T15:04", ctx.QueryParam("sell_time"), global.TimeLocal)
		if err != nil {
			global.Logger.Error("sell_time数据类型转换是失败：" + err.Error())
			query.SellTime = 0
		}
		query.SellTime = t.Unix()
	}
	if query.SellTime != 0 && query.BuyTime != 0 && query.SellTime < query.BuyTime {
		response["error"] = "订单结束时间不能小于订单购买时间"
		return ctx.JSON(200, response)
	}
	//根据条件查询订单
	res, err := Model.GetOrder(&query, []string{}, &model.ListParams{})
	if err != nil {
		global.Logger.Error("查询订单错误：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}

	if len(res) == 0 {
		response["data"] = ""
	} else {
		response["data"] = res
	}

	//数据统计
	data_count := make(map[string]interface{})
	var Count int64
	//判断时间统计订单数据
	if query.SellTime != 0 && query.BuyTime != 0 {
		if _, err = global.DB.Query(&Count, `SELECT count(*) FROM order_trade_completed WHERE buy_time >= ? AND sell_time <= ?`,
			query.BuyTime, query.SellTime); err == nil {
			data_count["total_order_count"] = Count
		}
		//订单总额
		if _, err = global.DB.Query(&Count, `SELECT sum("amount") FROM order_trade_completed WHERE buy_time >= ? AND sell_time <= ?`,
			query.BuyTime, query.SellTime); err == nil {
			data_count["total_order_amount"] = Count
		}
		//用户盈利订单总数
		if _, err = global.DB.Query(&Count,
			`SELECT count(*) FROM order_trade_completed WHERE income_amount > ? AND buy_time >= ? AND sell_time <= ?`,
			0, query.BuyTime, query.SellTime); err == nil {
			data_count["income_order_count"] = Count
		}
		//用户盈利总额
		if _, err = global.DB.Query(&Count, `SELECT sum("income_amount") FROM order_trade_completed WHERE income_amount > ? AND buy_time >= ? AND sell_time <= ?`,
			0, query.BuyTime, query.SellTime); err == nil {
			data_count["income_order_amount"] = Count
		}
		//用户亏损订单总数
		if _, err = global.DB.Query(&Count, `SELECT count(*) FROM order_trade_completed WHERE income_amount < ? AND buy_time >= ? AND sell_time <= ?`,
			0, query.BuyTime, query.SellTime); err == nil {
			data_count["outcome_order_count"] = Count
		}
		//用户亏损总额
		if _, err = global.DB.Query(&Count, `SELECT sum("amount") FROM order_trade_completed WHERE income_amount < ? AND buy_time >= ? AND sell_time <= ?`,
			0, query.BuyTime, query.SellTime); err == nil {
			data_count["outcome_order_amount"] = Count
		}
	} else {
		if _, err = global.DB.Query(&Count, `SELECT count(*) FROM order_trade_completed`); err == nil {
			data_count["total_order_count"] = Count
		}
		//订单总额
		if _, err = global.DB.Query(&Count, `SELECT sum("amount") FROM order_trade_completed`); err == nil {
			data_count["total_order_amount"] = Count
		}
		//用户盈利订单总数
		if _, err = global.DB.Query(&Count, `SELECT count(*) FROM order_trade_completed WHERE income_amount > ?`, 0); err == nil {
			data_count["income_order_count"] = Count
		}
		//用户盈利总额
		if _, err = global.DB.Query(&Count, `SELECT sum("income_amount") FROM order_trade_completed WHERE income_amount > ?`, 0); err == nil {
			data_count["income_order_amount"] = Count
		}
		//用户亏损订单总数
		if _, err = global.DB.Query(&Count, `SELECT count(*) FROM order_trade_completed WHERE income_amount < ?`, 0); err == nil {
			data_count["outcome_order_count"] = Count
		}
		//用户亏损总额
		if _, err = global.DB.Query(&Count, `SELECT sum("amount") FROM order_trade_completed WHERE income_amount < ?`, 0); err == nil {
			data_count["outcome_order_amount"] = Count
		}
	}

	response["data_count"] = data_count

	_, err = global.DB.Query(&Items, `SELECT "id", "name" FROM item`)
	if err != nil {
		global.Logger.Error("查询产品错误：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	response["items"] = Items

	return ctx.JSON(200, response)
}

//删除历史订单
func (*Order) DeleteHistoryOrder(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""

	if ctx.Param("order_ids") == "" {
		response["error"] = "缺少参数order_ids"
		return ctx.JSON(200, response)
	}

	var deleteIDs []int64
	var stringIDs []string
	ids := ctx.Param("order_ids")
	stringIDs = strings.Split(ids, ",")
	for _, v := range stringIDs {
		id, err := strconv.ParseInt(v, 10, 64)
		if err != nil {
			global.Logger.Error("order_ids数据类型转换出错")
			response["error"] = "系统错误"
			return ctx.JSON(500, response)
		}
		deleteIDs = append(deleteIDs, id)
	}
	var Model model.OrderTradeCompletedModel
	var order_ids []model.OrderTradeCompleted
	err = global.DB.Model(&order_ids).Column("id").WhereIn("id IN (?)", pg.In(deleteIDs)).Select()
	if err != nil {
		global.Logger.Error("查找订单ID出错：" + err.Error())
		response["error"] = "系统错误"
		return ctx.String(500, err.Error())
	}
	if len(order_ids) != len(deleteIDs) {
		response["error"] = "参数中含有不存在的订单ID"
		return ctx.JSON(200, response)
	}

	//调用模型删除管理员
	err = Model.DeleteOrder(deleteIDs)
	if err != nil {
		global.Logger.Error("删除订单失败：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	return ctx.JSON(200, response)
}

//获取充值订单首页列表，包含统计数据
func (*Order) RechargeOrderIndex(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""

	var Model model.RechargeOrderModel
	var query model.RechargeOrder
	if ctx.QueryParam("mobile") != "" {
		query.UserID = GetUserID("mobile", ctx.QueryParam("mobile"))
	}
	if ctx.QueryParam("nickname") != "" {
		query.UserID = GetUserID("nickname", ctx.QueryParam("nickname"))
	}
	if ctx.QueryParam("fullname") != "" {
		query.UserID = GetUserID("fullname", ctx.QueryParam("fullname"))
	}

	if ctx.QueryParam("start_time") != "" {
		t, err := time.ParseInLocation("2006-01-02T15:04", ctx.QueryParam("start_time"), global.TimeLocal)
		if err != nil {
			global.Logger.Error("start_time数据类型转换是失败：" + err.Error())
			query.StartTime = 0
		}
		query.StartTime = t.Unix()
	}
	if ctx.QueryParam("end_time") != "" {
		t, err := time.ParseInLocation("2006-01-02T15:04", ctx.QueryParam("end_time"), global.TimeLocal)
		if err != nil {
			global.Logger.Error("end_time数据类型转换是失败：" + err.Error())
			query.EndTime = 0
		}
		query.EndTime = t.Unix()
	}
	if query.StartTime != 0 && query.EndTime != 0 && query.StartTime > query.EndTime {
		response["error"] = "充值发起时间不能大于完成时间"
		return ctx.JSON(200, response)
	}

	//根据条件进行查询
	res, err := Model.GetOrder(&query, []string{}, &model.ListParams{})
	if err != nil {
		global.Logger.Error("查询订单失败：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	if len(res) == 0 {
		response["data"] = ""
	} else {
		response["data"] = res
	}
	//充值、提现数据统计
	result1 := DataCount("recharge_order", query.StartTime, query.EndTime)
	result2 := DataCount("withdraw_order", query.StartTime, query.EndTime)
	response["recharge_data_count"] = result1
	response["withdraw_data_count"] = result2
	return ctx.JSON(200, response)
}

//删除充值订单
func (*Order) DeleteRechargeOrder(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""

	if ctx.Param("order_ids") == "" {
		response["error"] = "缺少参数order_ids"
		return ctx.JSON(200, response)
	}

	var deleteIDs []int64
	var stringIDs []string
	ids := ctx.Param("order_ids")
	stringIDs = strings.Split(ids, ",")
	for _, v := range stringIDs {
		id, err := strconv.ParseInt(v, 10, 64)
		if err != nil {
			global.Logger.Error("order_ids数据类型转换出错")
			response["error"] = "系统错误"
			return ctx.JSON(500, response)
		}
		deleteIDs = append(deleteIDs, id)
	}
	var Model model.RechargeOrderModel
	var order_ids []model.RechargeOrder
	err = global.DB.Model(&order_ids).Column("id").WhereIn("id IN (?)", pg.In(deleteIDs)).Select()
	if err != nil {
		global.Logger.Error("查找订单ID出错：" + err.Error())
		response["error"] = "系统错误"
		return ctx.String(500, err.Error())
	}
	if len(order_ids) != len(deleteIDs) {
		response["error"] = "参数中含有不存在的订单ID"
		return ctx.JSON(200, response)
	}

	//调用模型删除管理员
	err = Model.DeleteOrder(deleteIDs)
	if err != nil {
		global.Logger.Error("删除订单失败：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	return ctx.JSON(200, response)
}

//获取提现订单首页列表，包含统计数据
func (*Order) WithdrawOrderIndex(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""

	var Model model.WithdrawOrderModel
	var query model.WithdrawOrder
	if ctx.QueryParam("mobile") != "" {
		query.Mobile = ctx.QueryParam("mobile")
	}
	if ctx.QueryParam("name") != "" {
		query.Name = ctx.QueryParam("fullname")
	}
	if ctx.QueryParam("nickname") != "" {
		query.UserID = GetUserID("nickname", ctx.QueryParam("nickname"))
	}
	if ctx.QueryParam("start_time") != "" {
		t, err := time.ParseInLocation("2006-01-02T15:04", ctx.QueryParam("start_time"), global.TimeLocal)
		if err != nil {
			global.Logger.Error("start_time数据类型转换是失败：" + err.Error())
			query.StartTime = 0
		}
		query.StartTime = t.Unix()
	}
	if ctx.QueryParam("end_time") != "" {
		t, err := time.ParseInLocation("2006-01-02T15:04", ctx.QueryParam("end_time"), global.TimeLocal)
		if err != nil {
			global.Logger.Error("end_time数据类型转换是失败：" + err.Error())
			query.EndTime = 0
		}
		query.EndTime = t.Unix()
	}
	if query.StartTime != 0 && query.EndTime != 0 && query.StartTime > query.EndTime {
		response["error"] = "充值发起时间不能大于完成时间"
		return ctx.JSON(200, response)
	}

	//根据条件进行查询
	res, err := Model.GetOrder(&query, []string{}, &model.ListParams{})
	if err != nil {
		global.Logger.Error("查询订单失败：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	if len(res) == 0 {
		response["data"] = ""
	} else {
		response["data"] = res
	}
	//充值、提现数据统计
	result1 := DataCount("recharge_order", query.StartTime, query.EndTime)
	result2 := DataCount("withdraw_order", query.StartTime, query.EndTime)
	response["recharge_data_count"] = result1
	response["withdraw_data_count"] = result2
	return ctx.JSON(200, response)
}

//显示单个提现订单详情
func (*Order) WithdrawOrderShow(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""
	var Model model.WithdrawOrderModel
	if ctx.Param("order_id") == "" {
		response["error"] = "缺少参数order_id"
		return ctx.JSON(200, response)
	}
	order_id, err := strconv.ParseInt(ctx.Param("order_id"), 10, 64)
	if err != nil {
		global.Logger.Error("order_id数据类型转换出错：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	res, err := Model.GetOrder(&model.WithdrawOrder{ID: order_id}, []string{}, &model.ListParams{Limit: 1})
	if err != nil {
		global.Logger.Error("查询提现订单出错：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	if len(res) == 0 || res[0].ID == 0 {
		response["error"] = "提现订单不存在"
		return ctx.JSON(200, response)
	}
	response["data"] = res[0]

	return ctx.JSON(200, response)
}

//修改提现订单
func (*Order) WithdrawOrderEdit(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""

	var Model model.WithdrawOrderModel
	var query model.WithdrawOrder

	if ctx.Param("order_id") == "" {
		response["error"] = "缺少参数order_id"
		return ctx.JSON(200, response)
	}
	query.ID, err = strconv.ParseInt(ctx.Param("order_id"), 10, 64)
	if err != nil {
		global.Logger.Error("order_id数据类型转换出错：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}

	if ctx.FormValue("amount") != "" {
		amount, err := strconv.ParseFloat(ctx.FormValue("amount"), 64)
		if err != nil {
			global.Logger.Error("amount数据类型转换出错：" + err.Error())
			response["error"] = "系统错误"
			return ctx.JSON(500, response)
		}
		query.Amount = int64(amount * 100) //乘100，单位变为分
	}
	if ctx.FormValue("name") != "" {
		if validation.FullName(ctx.FormValue("name")) == true {
			query.Name = ctx.FormValue("name")
		}
	}
	if ctx.FormValue("bank_number") != "" {
		query.BankNumber = ctx.FormValue("bank_number")
	}
	if ctx.FormValue("mobile") != "" {
		if validation.Mobile(ctx.FormValue("mobile")) == true {
			query.Mobile = ctx.FormValue("mobile")
		}
	}
	if ctx.FormValue("idcard_number") != "" {
		if validation.IDCard(ctx.FormValue("idcard_number")) == true {
			query.IDCardNumber = ctx.FormValue("idcadr_number")
		}
	}
	if ctx.FormValue("bank_name") != "" {
		query.BankName = ctx.FormValue("bank_name")
	}
	if ctx.FormValue("bank_branch") != "" {
		query.BankBranch = ctx.FormValue("bank_branch")
	}
	if ctx.FormValue("status") == "true" {
		query.Status = true
	}

	err = Model.EditOrder(&query)
	return ctx.JSON(200, response)
}

//删除提现订单
func (*Order) DeleteWithdrawOrder(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""

	if ctx.Param("order_ids") == "" {
		response["error"] = "缺少参数order_ids"
		return ctx.JSON(200, response)
	}

	var deleteIDs []int64
	var stringIDs []string
	ids := ctx.Param("order_ids")
	stringIDs = strings.Split(ids, ",")
	for _, v := range stringIDs {
		id, err := strconv.ParseInt(v, 10, 64)
		if err != nil {
			global.Logger.Error("order_ids数据类型转换出错")
			response["error"] = "系统错误"
			return ctx.JSON(500, response)
		}
		deleteIDs = append(deleteIDs, id)
	}
	var Model model.WithdrawOrderModel
	var order_ids []model.WithdrawOrder
	err = global.DB.Model(&order_ids).Column("id").WhereIn("id IN (?)", pg.In(deleteIDs)).Select()
	if err != nil {
		global.Logger.Error("查找订单ID出错：" + err.Error())
		response["error"] = "系统错误"
		return ctx.String(500, err.Error())
	}
	if len(order_ids) != len(deleteIDs) {
		response["error"] = "参数中含有不存在的订单ID"
		return ctx.JSON(200, response)
	}

	//调用模型删除管理员
	err = Model.DeleteOrder(deleteIDs)
	if err != nil {
		global.Logger.Error("删除订单失败：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	return ctx.JSON(200, response)
}

//处理提现
func (*Order) WithdrawOrderOperate(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""

	var WithdrawModel model.WithdrawOrderModel
	var query model.WithdrawOrder
	if ctx.Param("order_id") != "" {
		order_id, err := strconv.ParseInt(ctx.Param("order_id"), 10, 64)
		if err != nil {
			global.Logger.Error("order_id数据类型转换出错：" + err.Error())
			response["error"] = "系统错误"
			return ctx.JSON(500, response)
		}
		query.ID = order_id
	}
	//查找提现订单
	res, err := WithdrawModel.GetOrder(&query, []string{}, &model.ListParams{Limit: 1})
	if err != nil {
		global.Logger.Error("查找提现订单出错：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	if len(res) == 0 || res[0].ID == 0 {
		response["error"] = "订单不存在"
		return ctx.JSON(200, response)
	}
	if res[0].Status == true {
		response["error"] = "订单状态为已完成状态"
		return ctx.JSON(200, response)
	}

	if res[0].QueryStatus == true {
		response["error"] = "该订单已发起提现请求，请查询订单状态"
		return ctx.JSON(200, response)
	}
	//后续逻辑暂未完成
	//开始后续逻辑
	daiFuPost := PostXuanDaiFu(&res[0]) //发送代付请求
	if daiFuPost["status"] == true {
		_, err = global.DB.Exec(`UPDATE withdraw_order SET query_status = ? WHERE id = ?`, true, res[0].ID)
		if err != nil {
			global.Logger.Error("修改订单状态出错：" + err.Error())
			response["error"] = "系统错误"
			return ctx.JSON(200, response)
		}
	} else {
		response["error"] = daiFuPost["msg"]
	}
	return ctx.JSON(200, response)
}

func (*Order) WithdrawStatusQuery(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""

	var WithdrawModel model.WithdrawOrderModel
	var query model.WithdrawOrder
	if ctx.Param("order_id") != "" {
		order_id, err := strconv.ParseInt(ctx.Param("order_id"), 10, 64)
		if err != nil {
			global.Logger.Error("order_id数据类型转换出错：" + err.Error())
			response["error"] = "系统错误"
			return ctx.JSON(500, response)
		}
		query.ID = order_id
	}
	//查找提现订单
	res, err := WithdrawModel.GetOrder(&query, []string{}, &model.ListParams{Limit: 1})
	if err != nil {
		global.Logger.Error("查找提现订单出错：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	if len(res) == 0 || res[0].ID == 0 {
		response["error"] = "订单不存在"
		return ctx.JSON(200, response)
	}
	if res[0].Status == true {
		response["error"] = "订单状态为已完成状态"
		return ctx.JSON(200, response)
	}
	//发起状态查询
	if res[0].QueryStatus == false {
		response["error"] = "该订单尚未发起提现,请先发起提现请求"
		return ctx.JSON(200, response)
	}
	//发送代付查询
	daiFuQuery := QueryXuanDaiFu(&res[0])
	if daiFuQuery["resp_cd"] != "0000" {
		response["error"] = "查询失败"
		return ctx.JSON(200, response)
	}
	if daiFuQuery["status"] == 10 {
		response["message"] = "处理中"
	}
	if daiFuQuery["status"] == 11 {
		response["message"] = "处理成功"
		global.DB.Exec(`UPDATE withdraw_order SET status = ? WHERE id = ?`, true, res[0].ID)

	}
	if daiFuQuery["status"] == 12 {
		response["message"] = "处理失败"
	}
	return ctx.JSON(200, response)
}

//重置提现订单状态
func (*Order) WithdrawStatusReset(ctx echo.Context) (err error) {
	response := make(map[string]interface{})
	response["error"] = ""
	id, err := strconv.ParseInt(ctx.Param("order_id"), 10, 64)
	if err != nil {
		global.Logger.Error("order_id数据类型转换出错：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	ID := global.IDNode.Generate()
	_, err = global.DB.Exec(`UPDATE withdraw_order SET id = ? , query_status = ? WHERE id = ?`, ID.Int64(), false, id)
	if err != nil {
		global.Logger.Error("修改订单出错：" + err.Error())
		response["error"] = "系统错误"
		return ctx.JSON(500, response)
	}
	return ctx.JSON(200, response)
}
